import java.util.Arrays;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-02-20
 * Time: 22:35
 */
public class Test {
    public static void initArrayOrder(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }

    public static void initArrayNotOrder(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_000);
        }
    }


    public static void testBubbleSort(int[] array) {
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序时间耗时:" + (endTime - startTime));
    }



    public static void main1(String[] args) {
        int[] array = new int[10_000];
        initArrayNotOrder(array);
        testBubbleSort(array);
    }

    public static void main2(String[] args) {
        int[] array = {88,12, 24, 32, 11, 9, 44, 56, 78};
        Sort.bubbleSort(array);
        System.out.println(Arrays.toString(array));
        Sort.quickSort(array);
    }


    public static void main(String[] args) {
        int[] array = {88,12, 24, 32, 11, 9, 44, 56, 78};
        Sort.quickSort1(array);
        System.out.println(Arrays.toString(array));
    }

    public static void testQuickSort(int[] array) {
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序时间耗时:" + (endTime - startTime));
    }

    public static void main4(String[] args) {
        int[] array = new int[10_000];
        initArrayNotOrder(array);
        testQuickSort(array);
    }

}
